<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="org.apache.struts2.components.Include"%>
<%@include file="../common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<title>产品</title>
		<link type="text/css" href="${ctx}/css/style.css" rel="stylesheet" />
		<link type="text/css" href="${ctx}/css/forms.css" rel="stylesheet" />
		<link type="text/css" href="${ctx}/js/jquery.ui.css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
		<script type="text/javascript" src="${ctx}/js/common.js"></script>
		<script type="text/javascript" src="${ctx}/js/page.js"></script>
		<script type="text/javascript">
			function resetForm() {
				$("#product_name").val("");
			}
			
			function search() {
				$("#form").submit();
			}
			
			function del(id) {
				if (confirm("确定要删除该产品吗？")) {
					window.location.href = "${ctx}/product/product!delete.action?id=" + id;
				}
			}
			
			function batchDelete() {
				var len = $("input:checkbox[name='ids']:checked").length;
				if (len == 0) {
					alert("请选择要删除的产品");
					return false;
				} else if (confirm("确定要删除这" + len +"个产品吗？")) {
					$("#form").attr("action", "${ctx}/product/product!batchDelete.action");
					$("#form").submit();
				}
			}
		</script>
	</head>
	<body>
		<div class="titleDiv">
			<h1>配置产品</h1>
		</div>
		<form action="${ctx}/product/product.action" id="form" name="form" method="post">
			<table width="95%" border="0" cellpadding="0" cellspacing="0" align="center" style="margin: 0 30px;">
				<tr align="left">
					<td align="left" width="10%">产品名称：</td>
					<td width="30%"><input  id="product_name" name="product.name" value="${product.name}" /></td>
					<td align="right">
						<input type="button" value="查询" onclick="search();" />
						<input type="button" value="重置" onclick="resetForm();" />
						<input type="button" value="新增" onclick="window.location='${ctx}/product/product!input.action';" />
						<input type="button" value="删除" onclick="batchDelete();" />
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="0" class="datatable">
				<tr align="center">
					<td nowrap align="center" width="10px"><input type="checkbox" onclick="selectAll(document.getElementsByName('ids'), this.checked);" /></td>
					<td nowrap>产品名称</td>
					<td nowrap>产品描述</td>
					<td nowrap colspan="2" align="center" width="50px">操作</td>
				</tr>
				<c:forEach items="${page.result}" var="product">
					<tr align="center">
						<td nowrap><input type="checkbox" name="ids" value="${product.id}" /></td>
						<td nowrap>&nbsp;${product.name}</a></td>
						<td nowrap>&nbsp;${product.desc}</a></td>
						<td nowrap>
							<ul id="icons" class="ui-widget ui-helper-clearfix">
								<li title="修改" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-wrench" onclick="window.location.href='product!input.action?id=${product.id}'"></span></li>
							</ul>
						</td>
						<td>
							<ul id="icons" class="ui-widget ui-helper-clearfix">
								<li title="删除" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-trash" onclick="del('${product.id}');"></span></li>
							</ul>
						</td>
					</tr>
				</c:forEach>
			</table>
			<div style="width:90%;margin-left: 30px;margin-top: 10px;">
			 <%@include file="../common/page.jsp" %>
			</div>
		</form>
	</body>
</html>